﻿Rsd.define('Rsd.Faith.stores.MenuStore', {
    extend: 'Rsd.data.Store',
    xtype: 'menuStore',
    keyName:'id',
    proxy: {url: 'resources/storages/menutree.js', method: 'GET'},
    constructor: function (config) {
        config = config || {};
        Rsd.apply(this, config);
        var me = this;
    },
    load:function load(args ,callback) {

        var me = this;
        var _callback = function (data) {
            var _list = data||[];

            /*for(var i in _list)
            {

                Rsd.app.requestService('dev.addpage',{
                    name:_list[i].text,
                    text:_list[i].text,
                    viewType:_list[i].viewType,
                    modelType:_list[i].modelType,
                    code:i.padStart(2,'0'),
                    icon:_list[i].icon||'icon.empty'
                },function (rs) {
                    console.log(rs);
                });

                if(_list[i].children)
                {
                    for(var j in _list[i].children)
                    {
                        Rsd.app.requestService('dev.addpage',{
                            name:_list[i].children[j].text,
                            text:_list[i].children[j].text,
                            viewType:_list[i].children[j].viewType,
                            modelType:_list[i].children[j].modelType,
                            code:i.padStart(2,'0')+j.padStart(2,'0'),
                            icon:_list[i].children[j].icon||'icon.empty'
                        },function (rs) {
                            console.log(rs);
                        });
                    }
                }
            }*/
            me.menu = Rsd.create('Rsd.data.Menu',{text:'根节点',children:data});

            callback.call(me,me.menu);
        }
        me.callParent(args,_callback)
    }
});
